public class Solution1764 {
    public boolean canChoose(int[][] groups, int[] nums) {
        int j=0;
        for (int i=0;i<groups.length;i++){
            while (true){
                boolean flag=true;
                for (int k=0;k<groups[i].length;k++){
                    if (j+k>=nums.length){
                        return false;
                    }
                    if (groups[i][k]!=nums[j+k]){
                        flag=false;
                        break;
                    }
                }
                if (flag){
                    j+=groups[i].length;
                    break;
                }else {
                    j++;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1764().canChoose(new int[][]{{1,-1,-1},{3,-2,0}},new int[]{1,-1,0,1,-1,-1,3,-2,0}));
    }
}
